import com.java.demo.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App2 {
    public static void main(String[] args) {
        //1、得到容器对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2、得到Bean对象
        UserRepository userRepository= context.getBean("userRepository", UserRepository.class);
        //3、调用Bean方法
        userRepository.sayHi();

        UserComponent userComponent= context.getBean("userComponent", UserComponent.class);
        userComponent.sayHi();

        UserConfiguration userConfiguration= context.getBean("userConfiguration", UserConfiguration.class);
        userConfiguration.sayHi();

        UserService userService= context.getBean("userService", UserService.class);
        userService.sayHi();
    }
}
